package com.example.ui.contact.chat;

import android.content.Context;
import android.content.SharedPreferences;

public class SharePreferenceUtil {
	public static final String MESSAGE_NOTIFY_KEY = "message_notify";
	public static final String MESSAGE_SOUND_KEY = "message_sound";
	public static final String SHOW_HEAD_KEY = "show_head";
	private SharedPreferences sp;
	private SharedPreferences.Editor editor;

	
//	public int MSG_NOTICE = 0;
//	public int MSG_ME = 0;
//	public int MSG_COMMENT = 0;	
//	public int MSG_FUNS= 0;
//	public int MSG_FRIEND = 0;
//	public int MSG_MSG = 0;
	
	public SharePreferenceUtil(Context context, String file) {
		sp = context.getSharedPreferences(file, Context.MODE_PRIVATE);
		editor = sp.edit();
	}

	// appid
	public void setAppId(String appid) {
		editor.putString("appid", appid);
		editor.commit();
	}

	public String getAppId() {
		return sp.getString("appid", "");
	}

	// user_id
	public void setUserId(String userId) {
		editor.putString("userid", userId);
		editor.commit();
	}

	public String getUserId() {
		return sp.getString("userid", "");
	}


	public void setMobile(String userId) {
		editor.putString("mobile", userId);
		editor.commit();
	}

	public String getMobile() {
		return sp.getString("mobile", "15221653266");
	}   
	
	public void setPushId2(String pushId){
	  editor.putString("pushid2", pushId);
	  editor.commit();	
    }

    public String getPushId2(){
	   return sp.getString("pushid2", "");
    }
	// channel_id
	public void setChannelId(String ChannelId) {
		editor.putString("ChannelId", ChannelId);
		editor.commit();
	}

	public String getChannelId() {
		return sp.getString("ChannelId", "");
	}

	// nick
	public void setNick(String nick) {
		editor.putString("nick", nick);
		editor.commit();
	}

	public String getNick() {
		return sp.getString("nick", "Leone");
	}

	

	// 头像图标
	public int getHeadIcon() {
		return sp.getInt("headIcon", 0);
	}

	public void setHeadIcon(int icon) {
		editor.putInt("headIcon", icon);
		editor.commit();
	}

	// 设置Tag
	public void setTag(String tag) {
		editor.putString("tag", tag);
		editor.commit();
	}

	public String getTag() {
		return sp.getString("tag", "");
	}

	//Leone add
	public void setPushId(String pushId){
		editor.putString("pushid", pushId);
		editor.commit();	
	}
	
	public String getPushId(){
		return sp.getString("pushid", "");
	}
	

	// 是否通知
	public boolean getMsgNotify() {
		return sp.getBoolean(MESSAGE_NOTIFY_KEY, false);
	}

	public void setMsgNotify(boolean isChecked) {
		editor.putBoolean(MESSAGE_NOTIFY_KEY, isChecked);
		editor.commit();
	}

	// 是否有声音
	public boolean getMsgSound() {
		return sp.getBoolean(MESSAGE_SOUND_KEY, true);
	}

	public void setMsgSound(boolean isChecked) {
		editor.putBoolean(MESSAGE_SOUND_KEY, isChecked);
		editor.commit();
	}

	// 是否显示自己头像
	public boolean getShowHead() {
		return sp.getBoolean(SHOW_HEAD_KEY, true);
	}

	public void setShowHead(boolean isChecked) {
		editor.putBoolean(SHOW_HEAD_KEY, isChecked);
		editor.commit();
	}

	// 表情翻页效果
	public int getFaceEffect() {
		return sp.getInt("face_effects", 3);
	}

	public void setFaceEffect(int effect) {
		if (effect < 0 || effect > 11)
			effect = 3;
		editor.putInt("face_effects", effect);
		editor.commit();
	}

	/**
	 * 保存通知消息数目
	 * @param mSG_NOTICE
	 */
	public int getMSG_NOTICE() {
		return sp.getInt("MSG_NOTICE", 0);
	}

	public void setMSG_NOTICE(int MSG_NOTICE) {
		editor.putInt("MSG_NOTICE", MSG_NOTICE);
		editor.commit();
	}

	public int getMSG_ME() {
		return sp.getInt("MSG_ME", 0);
	}

	public void setMSG_ME(int MSG_ME) {
		editor.putInt("MSG_ME", MSG_ME);
		editor.commit();
	}

	public int getMSG_COMMENT() {
		return sp.getInt("MSG_COMMENT", 0);
	}

	public void setMSG_COMMENT(int MSG_COMMENT) {
		editor.putInt("MSG_COMMENT", MSG_COMMENT);
		editor.commit();
	}

	public int getMSG_FUNS() {
		return sp.getInt("MSG_FUNS", 0);
	}

	public void setMSG_FUNS(int MSG_FUNS) {
		editor.putInt("MSG_FUNS", MSG_FUNS);
		editor.commit();
	}

	public int getMSG_FRIEND() {
		return sp.getInt("MSG_FRIEND", 0);
	}

	public void setMSG_FRIEND(int MSG_FRIEND) {
		editor.putInt("MSG_FRIEND", MSG_FRIEND);
		editor.commit();
	}

	public int getMSG_CHAT() {
		return sp.getInt("MSG_CHAT", 0);
	}

	public void setMSG_CHAT(int MSG_CHAT) {
		editor.putInt("MSG_CHAT", MSG_CHAT);
		editor.commit();
	}

	public void setLogin(boolean isLogin){
		editor.putBoolean("isLogin", isLogin);
		editor.commit();		
	}
	public boolean getLogin(){
		return sp.getBoolean("isLogin", false);
	}

}
